import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2023-04-21
 * Time: 21:52
 */
public class sortDeom1 {
    public static void main(String[] args) {
        int[] a = {5,4,3,6,2};
        insertSort(a);
        System.out.println(Arrays.toString(a));
    }

    private static void insertSort(int[] a) {
        for (int i = 1; i < a.length; i++) {
            int tmp = a[i];
            int j = i-1;
            for (; j >= 0; j--) {
                if(a[j] >= tmp){
                    a[j+1] = a[j];
                }else {
                    break;
                }
            }
            a[j+1] = tmp;

        }
    }
}
